/**
 * -----------------------------------
 *  Copyright (c) 2021-2023
 *  All rights reserved, Designed By www.linfeng.tech
 * 林风社交论坛商业版本请务必保留此注释头信息
 * 商业版授权联系技术客服	 QQ:  3582996245
 * 严禁分享、盗用、转卖源码或非法牟利！
 * 版权所有 ，侵权必究！
 * -----------------------------------
 */
package io.linfeng.modules.app.controller;

import cn.hutool.json.JSONObject;
import io.linfeng.common.utils.R;
import io.linfeng.modules.admin.entity.AppUserEntity;
import io.linfeng.modules.app.annotation.Login;
import io.linfeng.modules.app.annotation.LoginUser;
import io.linfeng.modules.app.param.DeleteFriendForm;
import io.linfeng.modules.app.service.FriendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @author linfeng
 * @date 2022/11/16 16:55
 */
@RestController
@RequestMapping("app/friend")
@Api(tags = "移动端——好友")
public class AppFriendController {

    @Autowired
    private FriendService friendService;


    @Login
    @GetMapping("/list")
    @ApiOperation("获取好友列表")
    public R getFriendList(@ApiIgnore @LoginUser AppUserEntity user){
        List<JSONObject> list=friendService.getFriendList(user.getUid());
        return R.ok().put("data",list);
    }

    @Login
    @PostMapping("/deleteFriend")
    @ApiOperation("删除指定好友")
    public R deleteFriend(@ApiIgnore @LoginUser AppUserEntity user,
                          @RequestBody DeleteFriendForm param){
        friendService.deleteFriend(param.getId(),user.getUid());
        return R.ok();
    }

}
